In [1]:
import itertools as it
import numpy as np
import scipy as sp
import pandas as pd
In [2]:
list(it.permutations([1,2,3], 2)) # 2 represents number of values in a set
Out[2]:
In [3]:
len(list(it.permutations([1,2,3], 2)))
Out[3]:
In [4]:
# With replacement
["".join(p) for p in it.permutations("122")]
Out[4]:
In [5]:
len(["".join(p) for p in it.permutations("122")])
Out[5]:
In [6]:
list(it.combinations([1,2,3],2))
Out[6]:
In [7]:
len(list(it.combinations([1,2,3],2)))
Out[7]:
In [8]:
# With replacement
list(it.combinations_with_replacement([1,2,3],2))
Out[8]:
In [9]:
len(list(it.combinations_with_replacement([1,2,3],2)))
Out[9]:
In [10]:
np.mean([5,2,4,3,6])
Out[10]:
In [11]:
np.average([5,2,4,3,6], weights = [1, 2, 1, 3, 4])
Out[11]:
In [12]:
from scipy import stats
stats.hmean([5,2,4,3,6])
Out[12]:
In [13]:
stats.gmean([5,2,4,3,6])
Out[13]:
In [14]:
np.median([5, 10, 24, 456])
Out[14]:
In [15]:
sp.stats.mode([5, 4, 21, 1, 4, 2, 5, 1, 1])
Out[15]:
In [16]:
# Minimum
print(np.min([50,6,5,8]))
# Maximum
print(np.max([50,6,5,8]))
# Range = Maximum - Minumum
np.ptp([50,6,5,8])
Out[16]:
In [17]:
np.var([1,1,10],ddof=0) # ddof - degrees of freedom which defines N of denominator in variance formula.
# ddof = 0 means N | ddof = 1 means N - 1
Out[17]:
In [18]:
np.std([20, 1, 5])
Out[18]:
In [19]:
stats.zscore([50, 10, 20])
Out[19]:
In [20]:
sp.stats.mstats.mquantiles([5,2,4,3,6]) # 0.25 | 0.50 | 0.75
Out[20]:
In [21]:
sp.stats.iqr([5,2,4,3,6])
Out[21]:
In [22]:
pd.Series([5, 2, 4, 3, 6]).describe()
Out[22]:
In [23]:
sp.stats.mstats.skew([5, 2, 350, 112, 22, 1000]) # right skewed
Out[23]:
In [24]:
sp.stats.mstats.skew([-80, -52, 3, 2]) # left skewed
Out[24]:
In [25]:
sp.stats.mstats.kurtosis([210, 55, 10, 20, 33, 4])
Out[25]:
In [ ]: